"""
auth : ginger
    其实没什么用
    生成参数 , show() 方法会返回字典
    该字典值存储的是报告接口返回信息中 , 有用的信息 ( 功能用例 , 接口用例 , 场景用例 , 性能用例 , 所有用例 )
"""

import time


class ReportData:

    def __init__(self, data_di):
        self.id = data_di.get('id'),  # id没啥用 , 同名用户已被 admin 处理过了 .
        self.name = data_di.get('name').split('\n')[0]
        self.all_count = data_di.get('allCount')
        self.test_case_count = data_di.get('testCaseCount')
        self.api_case_count = data_di.get('apiCaseCount')
        self.scenario_case_count = data_di.get('scenarioCaseCount')
        self.load_case_count = data_di.get('loadCaseCount')

    def show(self, workspace, project):
        data_li = [
            workspace,
            project,
            self.name,
            self.test_case_count,
            self.scenario_case_count,
            self.api_case_count,
            self.load_case_count,
            self.all_count
        ]
        return data_li


if __name__ == '__main__':
    """
    from common.do_requests import request
    from common.do_token import headers

    url_path = r'/report/test/case/count/getReport'
    method = 'POST'
    headers = headers
    param = {
        "xaxis": "creator",
        "yaxis": ["testCase", "apiCase", "scenarioCase", "loadCase"],
        "timeType": "dynamicTime",
        "projectId": "83e6df74-a6b7-4429-a2e3-b6fb1a9f6ab1",
        "filterType": "And",
        "timeFilter": {"timeRange": 7, "timeRangeUnit": "day"},
        "times": [1678338587535, 1678856987535],
        "filters": [{"type": "", "name": "", "compType": "input", "isShow": False}]
    }
    res = request(path=url_path, method=method, headers=headers, param=param)
    result = res.json()
    print(result)
    li = result.get('data').get('tableDTOs')
    for item in li:
        sd = ReportData(item)
        data_s = sd.show('易盘点', '易盘点')
        print(data_s)
    """
    """
    real_data_di = {
        "id": "2cf15a6d-376a-46d8-ad35-2f9b2c894213",
        "name": "田振宇\n(tianzhenyu)",
        "allCount": "28",
        "testCaseCount": "20",
        "apiCaseCount": "0",
        "scenarioCaseCount": "8",
        "loadCaseCount": "0",
        "children": []
    }

    sd = ShowData(
        real_data_di.get('id'),
        real_data_di.get('name'),
        real_data_di.get('allCount'),
        real_data_di.get('testCaseCount'),
        real_data_di.get('apiCaseCount'),
        real_data_di.get('scenarioCaseCount'),
        real_data_di.get('loadCaseCount'),
    )

    data_s = sd.show('易盘点', '易盘点')

    print(data_s)
    """

    print(str(time.time()).split('.')[0])
    print(str(time.time() - 60 * 60 * 24 * 7).split('.')[0])
